package com.symone.webcms.service.impl;

import com.symone.webcms.model.Slide;
import com.symone.webcms.mapper.SlideMapper;
import com.symone.webcms.service.SlideService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 *　　
 *   @description : Slide 服务实现类
 *   ---------------------------------
 * 	 @author Archer Chu
 *   @since 2019-03-29
 */
@Service
public class SlideServiceImpl extends ServiceImpl<SlideMapper, Slide> implements SlideService {

    @Override
    public Page<Slide> findPage(Page<Slide> page, Wrapper<Slide> slide) {
        List<Slide> result = baseMapper.selectPage(page,slide);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<Slide> findAll() {
        Wrapper<Slide> ew = new EntityWrapper<Slide>();
        ew.where("deleted=0");
        return baseMapper.selectList(ew);
    }

    @Override
    public int delete(long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public boolean deleteFlagById(long id) {
        return baseMapper.deleteFlagById(id);
    }

    @Override
    public int clear() {
        return baseMapper.delete(new EntityWrapper<Slide>().eq("deleted" ,1));
    }
	
}
